home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group96a.txt
/
000015_icon-group-sender _Tue Jan 16 09:28:24 1996.msg
< prev
next >
Wrap
Internet Message Format
|
1996-09-05
|
1KB
Received: by cheltenham.cs.arizona.edu; Tue, 16 Jan 1996 12:30:17 MST
Date: Tue, 16 Jan 1996 09:28:24 -0700
From: swampler@noao.edu
Subject: Re: Initialising tables
To: H.Lawson@tees.ac.uk
Cc: icon-group@cs.arizona.edu
Message-Id: <swampler-9600161628.AA00097538@orpheus.gemini.edu>
In-Reply-To: <4B78DE79AC@scm_arkengarthdale.tees.ac.uk>
Errors-To: icon-group-errors@cs.arizona.edu
Status: O
Hamish Lawson wrote:
> Is there an quick way to initialise tables, along the lines of the
> list assignment below?
>
> aList := ["this","list","is","a","list"]
>
> I've cooked up the following, but is there a more concise way?
>
> aTable := table()
> every entry := ![["bob",2],["sue",5],["fred",12],["mary",9]] do
> aTable[entry[1]] := entry[2]
>
Well, this isn't any more concise in the short term, but it might be
better in the long run to use a procedure to do the initialization:
aTable := mktable(["bob",2],["sue",5],["fred",12],["mary",9])
where mktable() is:
procedure mktable(L[])
local aT, pair
aT := table()
every pair := !L do {
aT[pair[1]] := pair[2]
}
return aT
end
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
The Gods that smiled upon your birth are laughing now. -- fortune cookie